
#include "SnapCaculator.h"
#include <qdatetime.h>
#include <stdio.h>
#include <math.h>


SnapCaculator::SnapCaculator(Snap* fSnap, Snap* bSnap, Setting* setting) : m_fSnap(fSnap), m_bSnap(bSnap), m_setting(setting)
{
}




SnapCaculator::~SnapCaculator()
{
}



void SnapCaculator::caculateCar()
{
	if(isCarHappen())
	{

		QDateTime dateTime = QDateTime::currentDateTime();

		emit carHappenSignal(dateTime.toString());
		emit carHappenSignal();
	}
	m_fSnap->clearForNext();
	m_bSnap->clearForNext();
}



bool SnapCaculator::isCarHappen()
{
	int fCnt;
	int bCnt;
	m_fSnap->info(&fCnt);
	m_bSnap->info(&bCnt);
	printf("fCnt = %d\n", fCnt);
	printf("bCnt = %d\n", bCnt);
	if(fCnt - bCnt > 2 || bCnt - fCnt > 2)
	{
		return true;
	}
	return false;

}
